package com.shop.shop.controller;

import com.shop.shop.dao.OrderMapper;
import com.shop.shop.model.Chart;
import com.shop.shop.model.Order;
import com.shop.shop.model.OrderMysql;
import com.shop.shop.service.OrderService;
import com.shop.shop.util.MysqlTransferUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Resource
    OrderMapper orderMapper;
    @Autowired
    OrderService orderService;
    @RequestMapping("/get")
    public List<Order> getAllData(){
        return MysqlTransferUtils.transferToOrderList(orderMapper.getAllData());
    }

    @RequestMapping("/create")
    public Order createByChart(Chart chart){
        return orderService.createOrderByChart(chart);
    }

    @RequestMapping("/seckill")
    public Order createSecKillOrder(Long uid,Long gid){
        Order order=orderService.createSecKillOrder(uid,gid);
        return order;
    }

    @RequestMapping("/test")
    public String g(){
        String res=orderService.a();
        System.out.println(res);
        return res;
    }
}
